#ifndef _CPLANECONTROL_H_
#define _CPLANECONTROL_H_

#include "CGlobals.h"
#include "IControl.h"
#include "IrrArray.h"
#include "Vector3d.h"
#include "Vector2d.h"
#include "position2d.h"
#include "SColor.h"

// CPlaneControl allows the user to move an object by dragging
// the plane drawn on it.
class CPlaneControl : public IControl
{
	CPlaneControl (); // no default constructor
	CPlaneControl (const CPlaneControl&); // no copy constructor
	CPlaneControl& operator= (const CPlaneControl&); // no assignment

public:
	CPlaneControl (array<ISceneNode*> nodes, vector3df axis1, vector3df axis2, SColor normalColor, SColor highlightColor);
	virtual ~CPlaneControl ();

	virtual bool OnEvent (const SEvent& event);
	virtual void draw ();

private:
	ICameraSceneNode* m_camera;
	array<ISceneNode*> m_nodes;
	vector3df m_axis1;
	vector3df m_axis2;
	SColor m_normalColor;
	SColor m_highlightColor;
	bool m_activated;
	bool m_highlighted;
	array<vector3df> m_nodesStartPos;
	vector3df m_centroid;
	position2di m_mouseStartPos;

	void getScreenCoordinates (array<vector2df>* coordinates) const;
	bool onMouseEvent (const SEvent::SMouseInput& event);
	bool isPointOverControl (position2di pt) const;
	vector2df getScreenAxis1 () const;
	vector2df getScreenAxis2 () const;
};

#endif
